


//
//  NZhichengPingshenVC.m
//  nncloud
//
//  Created by macfai on 2018/11/23.
//  Copyright © 2018 macfai. All rights reserved.
//

#import "NZhichengPingshenVC.h"
#import "NZhiChengCell.h"
#import "NZhichengDetailViewController.h"
#import "NTitleEvaModel.h"
#import <WebKit/WebKit.h>
@interface NZhichengPingshenVC ()<UITableViewDataSource,UITableViewDelegate,WKUIDelegate,WKNavigationDelegate>

@property(nonatomic,strong)UITableView *tableView;

@property(nonatomic,strong)NSMutableArray *dataArray;

@end

@implementation NZhichengPingshenVC
#define cellIdentifier @"zhicheng"
#define SectionHeaderHeight  10.f

-(UITableView *)tableView{
    
    if (!_tableView) {
        
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0 , 0, ScreenWidth , ScreenHeight - 64) style:UITableViewStyleGrouped];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.rowHeight = 80.f;
        _tableView.backgroundColor = kBackgroundColor;
        [_tableView registerNib:[UINib nibWithNibName:@"NZhiChengCell" bundle:nil] forCellReuseIdentifier:cellIdentifier];
        _tableView.showsVerticalScrollIndicator = NO;
        //        _tableView.tableFooterView = [UIView new];
        
    }
    return _tableView;
}
- (void)viewDidLoad {
    
    [super viewDidLoad];
    self.dataArray = [NSMutableArray array];
    self.view.backgroundColor = kWhiteColor;
    [self.navigationItem setItemWithTitle:@"职称评审" textColor:kNavigationTitleColor fontSize:18 itemType:center];
    [self.view addSubview:self.tableView];
    
    [self loadData];
//    [self addWebView];
    // Do any additional setup after loading the view.
}

- (void)addWebView
{
    WKWebView *webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight-64-49)];
    //    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.baidu.com"]]];
    [self.view addSubview:webView];
    webView.UIDelegate = self;
    webView.navigationDelegate = self;
    NSString *strHTML = @"<p><strong>很经典的黑色后背纯雪纺透视装到货了哈</strong><strong>&nbsp;</strong></p><p><strong>前面莫代尔&nbsp;手感顺滑 柔软 &nbsp;手感不错</strong></p><p><strong>后面薄薄的雪纺纱</strong></p><p><strong>腰节处开叉</strong></p><p><strong>很大气，超有范儿的一款&nbsp; 这个年代随时随地 都可见的欧美街头范儿</strong></p><p><strong>后背透、透、透</strong></p><p><strong>165身高 96J穿起来大概在膝盖不到10CM的位置</strong></p><p>&nbsp;</p><p><strong>亲们啊~ 特别美得一款，穿起来超级有范，</strong></p><p><strong>看着特别不起眼的一件衣服，但上身效果特别好，</strong></p><p><strong>背面全部透视的雪纺黑纱，特别性感，</strong></p><p><strong>里面需要配一款黑色吊带，两侧带开叉的设计，亲们赶紧下手吧~~&middot;</strong></p><p>&nbsp;</p><p><strong>面料： 正面莫代尔背面：雪纺纱&nbsp;</strong></p><p><strong>Label:</strong>无主标 无尺码标&nbsp; 有吊牌 普通包装</p><p>&nbsp;</p><p><strong>Size</strong>：平铺尺寸,由于手工测量,会有2~3厘米的误差</p><p>~SIZE=CM</p><p>胸围：126连肩袖长：65&nbsp; 前衣长：80 后衣长：90</p><p>&nbsp;<img style=\"border-width:0;border-image-width:initial\" src=\"https://img.alicdn.com/imgextra/i4/676496646/T2zdB0X9NXXXXXXXXX_!!676496646.jpg\" width=\"100%\" height=\"((348 / 500) * 100)%\" align=\"absmiddle\">&nbsp;&nbsp;</p><p>&nbsp;</p>";
    [webView loadHTMLString:strHTML baseURL:nil];
    
}


- (void)loadData{
    
    //后期逐渐添加参数目前不需要参数
    
    [[NNRCNetRequest manager]getWithUrl:ktitleEvaluationUrl params:nil success:^(id result) {
        
        YYLog(@"%@",result);
        WeakStament(ws);
        if ([[result objectForKey:@"code"] integerValue] == 0) {

            NSArray *arr = result[@"page"][@"records"];
            YYLog(@"%@",arr);
            for (NSDictionary *dict in arr) {
                
                NTitleEvaModel *model = [NTitleEvaModel mj_objectWithKeyValues:dict];
                [ws.dataArray addObject:model];
            }
            [ws.tableView reloadData];

        }else{
            [AFToast showText:result[@"msg"]];
        }
        
    } failure:^(id failure) {
        
    }];
    
}

#pragma mark - datasource

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return self.dataArray.count;
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    NZhiChengCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
    NTitleEvaModel *model = self.dataArray[indexPath.section];
    cell.model = model;
    return cell;
}



#pragma mark - delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    NZhichengDetailViewController *detail = [NZhichengDetailViewController new];
    NTitleEvaModel *model = self.dataArray[indexPath.section];
    if (model) {
        detail.model = model;
    }
    [self.navigationController pushViewController:detail animated:YES];
}


#pragma mark - section head
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return SectionHeaderHeight;//如果设置section的header高度，不设置footer高度，footer默认等于header高度
}



- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, SectionHeaderHeight)];
    view.backgroundColor = kBackgroundColor;
    return view;
}

#pragma mark - section foot
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    return nil;
}


@end
